package com.wanxi.service;

import com.wanxi.dao.BrandDao;
import com.wanxi.model.BrandModel;
import com.wanxi.model.BrandModelError;

import java.util.List;

public class BrandService {
//    public int add(String brandName, String enterpriseName, String sort, String brandIntroduce, String style) {
//        return 0;
//    }

    public int add(BrandModel model) {
        if (model.getSort() < 0) {
            model.setSort(0);
        }
        if (model.getSort() > 100) {
            model.setSort(100);
        }
        BrandDao brandDao = new BrandDao();
        int count = brandDao.add(model);
        return count;
    }

    public List<BrandModel> findAll() {
        BrandDao brandDao = new BrandDao();
        return brandDao.findAll();
    }

    public int delete(BrandModel model) {
        BrandDao brandDao = new BrandDao();
        return brandDao.delete(model);
    }

    public BrandModel findById(BrandModel brandModel) {
        BrandDao brandDao = new BrandDao();
        return brandDao.findById(brandModel);
    }

    public int update(BrandModel model) {
        BrandDao brandDao = new BrandDao();
        int count = brandDao.update(model);
        return count;
    }
}
